// localStorage封装

const PREFIX = 'nantong_'

/**
 * 本地存储类
 */
class Storage {
  /**
   * 设置存储
   * @param key 键
   * @param value 值
   */
  set(key: string, value: any) {
    localStorage.setItem(PREFIX + key, value)
  }

  /**
   * 获取存储
   * @param key 键
   * @returns 值
   */
  get(key: string) {
    return localStorage.getItem(PREFIX + key)
  }

  /**
   * 移除存储
   * @param key 键
   */
  remove(key: string) {
    localStorage.removeItem(PREFIX + key)
  }

  /**
   * 清空所有存储
   */
  clear() {
    localStorage.clear()
  }
}

export const storage = new Storage()
